package games;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;

public class GamesPackage {
    public static void fingerGuessing() {
        System.out.println("Game Start. (1-剪刀 2-石头 3-布)");
        Map<Integer, String> map = new HashMap<>();
        map.put(1, "剪刀");
        map.put(2, "石头");
        map.put(3, "布");
        Random random = new Random();
        int round = 1;
        int playerWins = 0;
        int pcWins = 0;
        while((playerWins < 4) && (pcWins < 4)) {
            System.out.println("Round " + round + ", pls input 1 ~ 3.");
            Scanner sc = new Scanner(System.in);
            int playerInput = sc.nextInt();
            int computerInput = random.nextInt(3) + 1;
            System.out.print("You choose: " + map.get(playerInput) + " ,PC choose: " + map.get(computerInput) + ". ");
            if (playerInput == computerInput) {
                System.out.println("Draw.");
            } else if ((playerInput == 1 && computerInput == 3) ||
                    (playerInput == 2 && computerInput == 1) ||
                    (playerInput == 3 && computerInput == 2)) {
                System.out.println("You win.");
                playerWins++;
            } else {
                System.out.println("PC win.");
                pcWins++;
            }
            round++;
            System.out.println("");
        }
        System.out.println("Game Set. Your Point: " + playerWins + " PC Point: " + pcWins);
    }

    public static void test(int level) {
        if (level > 10 || level < 1) {
            System.out.println("Level In 1 ~ 10");
            return;
        }
        int withIn = 1100 - level * 100;
        Scanner sc = new Scanner(System.in);
        int min = 3000;
        int max = 8000;
        Random random = new Random();
        int steady = random.nextInt(max) % (max - min + 1) + min;
        try {
            random.nextInt();
            System.out.println("Ready...");
            Thread.sleep(2000);
            System.out.println("Steady...");
            Thread.sleep(steady);
            System.out.println("Shoot!");
            long start = System.currentTimeMillis();
            long end = start;
            if (sc.hasNext()) {
                end = System.currentTimeMillis();
            }
            long score = end - start;
            System.out.println(score);
            if (score <= withIn) {
                System.out.println("Congratulation!");
            } else {
                System.out.println("Lose...");
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
